class P10093 {

	public static void main(String[] args) {
		String line = readLn();
		while (line != null) {
			process(line);
			line = readLn();
		}
	}

	private static void process(String line) {
		
		
		int len = line.length();
		int val = 0;
		int max = 0;
		int sum = 0;
		int min_base;
		for(int a=0; a< len;a++)
	    {
			
			
	    if(!Character.isLetterOrDigit(line.charAt(a)))
	    	continue;
	    	
	    if(Character.isDigit(line.charAt(a)))
	    	val=line.charAt(a)-'0';
	    else if(Character.isLetter((line.charAt(a))) && line.charAt(a) >= 'A' && line.charAt(a) <= 'Z')
	      val=line.charAt(a) -'A'+10;
	    else if(Character.isLetter((line.charAt(a))) && line.charAt(a) >= 'a' && line.charAt(a) <= 'z')
		      val=line.charAt(a) -'a'+36;
	    if(val>max)
	     max=val;     
	    sum+=val;     
	    }

	 if(max==0 && sum==0)
	   System.out.println("2");
	 else
	   {
	 min_base=max+1;
	 boolean flag= true;
	 int b = 0;
	 for(b=min_base-1;;b++)
	   {
	   if((sum%b)==0)
	      break;
	   if(b>=61)
	     {
	     flag=false;
	     break;
	     }

	   }
	 if(flag)
	  System.out.println(b+1); 
	 else if(!flag)
	  System.out.println("such number is impossible!");
	  }
	 } 
		

	static String readLn() {
		String newLine = System.getProperty("line.separator");
		StringBuffer buffer = new StringBuffer();
		int car = -1;
		try {
			car = System.in.read();
			while ((car > 0) && (car != newLine.charAt(0))) {
				buffer.append((char) car);
				car = System.in.read();
			}
			if (car == newLine.charAt(0))
				System.in.skip(newLine.length() - 1);
		} catch (java.io.IOException e) {
			return (null);
		}
		if ((car < 0) && (buffer.length() == 0))
			return (null);
		return (buffer.toString()).trim();
	}

}
